home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
zbpc_460.zip
/
UTILITY.EXE
/
KEYTRAP.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-04-08
|
4KB
|
111 lines
DIM Key$(14),Keyname$(14),FunctionKey$(10),FKey$(10),OtherKey$(10),OKey$(10)
DIM ShiftFKey$(10),AltFKey$(10),CtrlFKey$(10),Bit$(14)
DEF SEG=0
COLOR ,31
CLS
PRINT @(0,17)"BIN$ &H417 = "
PRINT@(40,17)"BIN$ &H418 = "
PRINT@ (10,24)"Enter key combination to display or Press Space Bar to End"
PRINT@ (10,19)"If length of INKEY$ = 2 and RIGHT$ (INKEY$) is"
FOR X = 1 TO 14 : READ Keyname$(X),Bit$(X) : NEXT
FOR X = 1 TO 10
READ FunctionKey$(X),FKey$(X),ShiftFKey$(X),AltFKey$(X),CtrlFKey$(X)
NEXT
FOR X = 1 TO 10 : READ OtherKey$(X),OKey$(X) : NEXT
"KeyWatch"
Byte1 = PEEK(&H417) ' case sensitivity in ZB-PC
Byte2 = PEEK(&H418) ' variable names
'These values can be easily represented as bits in ZB-PC by the
'BIN$ function. Thus if Byte1 is 1, BIN$ is "0000000000000001"
'Byte1 value 5 would return BIN$ of "0000000000000101"
Key$(1) = "N" : IF Byte2 > 127 Key$(1) = "Y" : Byte2 = Byte2-128
Key$(2) = "N" : IF Byte2 > 63 Key$(2) = "Y" : Byte2 = Byte2-64
Key$(3) = "N" : IF Byte2 > 31 Key$(3) = "Y" : Byte2 = Byte2-32
Key$(4) = "N" : IF Byte2 > 15 Key$(4) = "Y" : Byte2 = Byte2-16
Key$(5) = "N" : IF Byte2 > 1 Key$(5) = "Y" : Byte2 = Byte2-2
Key$(6) = "N" : IF Byte2 > 0 Key$(6) = "Y"
' On my extended keyboards only the Left Control and Left ALT Key returns
' the above, the Right Control Key does nothing. This appears to be a way
' to trap the left versus the right Control and Alt keys, but more testing
' may be in order
Key$(7) = "N" : IF Byte1 > 127 Key$(7) = "Y" : Byte1 = Byte1-128
Key$(8) = "N" : IF Byte1 > 63 Key$(8) = "Y" : Byte1 = Byte1-64
Key$(9) = "N" : IF Byte1 > 31 Key$(9) = "Y" : Byte1 = Byte1-32
Key$(10) = "N" : IF Byte1 > 15 Key$(10) = "Y" : Byte1 = Byte1-16
Key$(11) = "N" : IF Byte1 > 7 Key$(11) = "Y" : Byte1 = Byte1-8
Key$(12) = "N" : IF Byte1 > 3 Key$(12) = "Y" : Byte1 = Byte1-4
Key$(13) = "N" : IF Byte1 > 1 Key$(13) = "Y" : Byte1 = Byte1-2
Key$(14) = "N" : IF Byte1 > 0 Key$(14) = "Y"
' The above can be done in ZB-PC with USR3(2)
FORX=1TO14
PRINT@(10,X)Key$(X),Keyname$(X),Bit$(X)
NEXT
PRINT@(15,16)BIN$(PEEK(&H417)):PRINT@(55,16)BIN$(PEEK(&H418))
KeyPressed$ = INKEY$ : IF KeyPressed$ = "" GOTO "KeyWatch"
IF KeyPressed$ = " " END
LONG IF LEN (KeyPressed$) = 2
Identity$ = RIGHT$(KeyPressed$,1)
FOR X = 1 TO 10
IF Identity$ = FKey$(X) PRINT@(0,21),FunctionKey$(X),,Identity$
NEXT
FOR X = 1 TO 10
IF Identity$ = ShiftFKey$(X) PRINT@(0,21),"Shifted "FunctionKey$(X),,Identity$
NEXT
FOR X = 1 TO 10
IF Identity$ = AltFKey$(X) PRINT@(0,21),"Alt "FunctionKey$(X),,Identity$
NEXT
FOR X = 1 TO 10
IF Identity$ = CtrlFKey$(X) PRINT@(0,21),"Control "FunctionKey$(X),,Identity$
NEXT
FOR X = 1 TO 10 : IF Identity$ = OKey$(X) PRINT@(0,21),OtherKey$(X),,Identity$
NEXT
END IF
GOTO "KeyWatch"
DATA"InsertKeyDown ",Bit 7 &H418
DATA"CapsLockKeyDown ",Bit 6 &H418
DATA"NumLockKeyDown ",Bit 5 &H418
DATA"ScrollLockKeyDown ",Bit 4 &H418
DATA"AltKeyDown ",Bit 1 &H418
DATA"ControlKeyDown ",Bit 0 &H418
DATA"InsertKeyLockedDown ",Bit 7 &H417
DATA"CapsLockKeyLockedDown ",Bit 6 &H417
DATA"NumLockKeyLockedDown ",Bit 5 &H417
DATA"ScrollLockKeyLockedDown",Bit 4 &H417
DATA"AltKeyDown ",Bit 3 &H417
DATA"ControlKeyDown ",Bit 2 &H417
DATA"LeftShiftKeyDown ",Bit 1 &H417
DATA"RightShiftKeyDown ",Bit 0 &H417
DATAF1,;,T,h,^
DATAF2,<,U,i,_
DATAF3,=,V,j,`
DATAF4,>,W,k,a
DATAF5,?,X,l,b
DATAF6,@,Y,m,c
DATAF7,A,Z,n,d
DATAF8,B,[,o,e
DATAF9,C,\,p,f
DATAF10,D,],q,g
DATAHome,G
DATACursor Up,H
DATAPage Up,I
DATACursor Left,K
DATACursor Right,M
DATAEnd,O
DATACursor Down,P
DATAPage Down,Q
DATAInsert,R
DATADelete,S